TransForm onSubmit Event BuilderSend SMS Message

Description

Sends an SMS message.

Discussion

The Send SMS Message sends an SMS message when a Form is submitted. The phone number to send the SMS message and the contents of the message can include information from the submitted Form data.

Configuring the Send SMS Message Action

The Send SMS Message Action Editor
The Send SMS Message Action Editor

The following properties are used to configure the Send SMS Message action.

  • General Properties

    TransForm Form Name

    The Form Type to send an SMS message for when the Form submitted.

    Condition

    Determines when the onSubmit action should be run.

    Your code must set the value of a variable called result to true or false. For example:

    Setting the result variable
    var result =  true;

    If true, the SMS message will be sent. If false, the SMS message is not sent. The next example demonstrates how to only send the SMS message when the metadata status field is set to 'closed':

    Checking the metadata status field to determine if an SMS message should be sent
    if (metadata.status.toLowerCase() == 'closed') {
        var result = true;
    } else {
        var result = false;
    }

    The code you define for the Condition can reference data in the submitted Form using the formdata and metadata variables.

    Prefix
    Description
    formdata

    A JavaScript object that contains the Form data submitted. You can use the Insert TransForm form field tool to insert a Form data field into your code if you have loaded sample Form data.

    metadata

    A JavaScript object that contains the meta data for the submitted Form. You can use the Insert TransForm form field tool to insert one of the following metadata variables into your code if you have loaded sample Form data:

    accountid

    The TransForm account ID associated with the Form.

    formid

    The Form Type ID of the Form.

    forminstanceid

    The unique instance ID of the Form.

    status

    The current status of the Form.

    person

    The User ID of the person assigned the Form instance.

    created

    The date/time the Form was created.

    completed

    The date/time when the Form's status was last changed.

    timestamp

    The date/time of when the Form was last inserted or updated in the server database.

    comments

    The representation of the JSON for the comments associated with the Form instance.

    nofiller

    Whether or not the Form should be downloaded to the filler application.

    duedate

    The value of the field in a Form instance that may be used to specify a date. It will either be blank or contain a date formatted as "yyyy-mm-dd". For example, "2024-04-16".

    user1, user2, user3, user4, user5, userlabel1, userlabel2, userlabel3, userlabel4, userlabel5

    The value of the extra fields in a Form instance reserved for use by the TransForm account's administrator.

    Description

    An optional description for the action. Shown in the onSubmit Actions list in TransForm Central.

  • Message Definition Properties

    Send to phone number

    The phone number where the SMS message should be sent.

    Your code must set the value of a variable called result to the phone number where the SMS message should be sent. The phone number must be specified in the format '+countryCodelocalPhoneNumber. For example:

    var result =  '+16179309123';

    The code you define for the Send to phone number can reference data in the submitted Form using the formdata and metadata variables. For example, the code below sets the recipient phone number to the value in the mobile Form field if the Form's status is 'closed'

    if (metadata.status.toLowerCase() == 'closed') {
        var result = formdata.mobile
    }

    See Condition above for more information about the formdata and metadata objects.

    Message body

    The SMS message to send.

    Your code must set the value of a variable called result to the text to send in the SMS message. For example:

    var message = 'Your data was received';
    var result = message;

    The code you define for the Message body can reference data in the submitted Form using the formdata and metadata variables. For example:

    var message = 'Your data was received for Form ' + metadata.formid;
    var result = message;

    See Condition above for more information about the formdata and metadata objects.

  • Twilio Settings Properties

    SID

    The Twilio account SID. Set to <system> to use the built-in TransForm Twilio account. Usage limits apply.

    Authorization code

    The Twilio authorization code. Set to <system> to use the built-in TransForm Twilio account. Usage limits apply.

    Phone number

    The Twilio phone number used to send the SMS message. Set to <system> to use the built-in TransForm Twilio account. Usage limits apply.